﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace MMS.UI.Areas.Admin.ViewModels
{
    public class MemberInfoModel
    {
        /// <summary>
        /// 会员编号
        /// </summary>
        public int MId { get; set; }
        [DisplayName("会员卡号"), Required(ErrorMessage = "会员卡号不能为空")]
        /// <summary>
        /// 会员卡号
        /// </summary>
        public string MCardId { get; set; }

        [DisplayName("会员等级"), Required(ErrorMessage = "会员等级不能为空")]
        /// <summary>
        /// 会员升级消费额
        /// </summary>
        public int MLId { get; set; }


        [DisplayName("会员姓名")]
        /// <summary>
        /// 会员姓名
        /// </summary>
        public string MName { get; set; }
        [DisplayName("会员余额"),DataType(DataType.Currency,ErrorMessage="会员余额必须为数字")]
        /// <summary>
        /// 会员余额
        /// </summary>
        public Decimal? MBalances { get; set; }
        [DisplayName("会员积分")]
        /// <summary>
        /// 会员积分
        /// </summary>
        public int? MIntegral { get; set; }

        [DisplayName("会员总消费额"),DataType(DataType.Currency,ErrorMessage="会员总消费额必须为数字")]
        /// <summary>
        /// 会员总消费额
        /// </summary>
        public decimal? MConsumption { get; set; }

        [DisplayName("会员出生日期")]
        [DataType(DataType.DateTime,ErrorMessage="会员出生日期格式不符合")]
        /// <summary>
        /// 会员出生日期
        /// </summary>
        public DateTime? MBirthday { get; set; }

        [DisplayName("会员性别")]
        /// <summary>
        /// 会员性别
        /// </summary>
        public string MGender { get; set; }

        [DisplayName("会员职业")]
        /// <summary>
        /// 会员职业
        /// </summary>
        public string MOccupation { get; set; }

        [DisplayName("会员号码")]
        [DataType(DataType.PhoneNumber, ErrorMessage = "会员号码")]
        /// <summary>
        /// 会员电话号码
        /// </summary>
        public string MPhone { get; set; }

        [DisplayName("会员密码")]
        /// <summary>
        /// 会员密码
        /// </summary>
        public string MPassword { get; set; }

        [DisplayName("会员地址")]
        /// <summary>
        /// 会员地址
        /// </summary>
        public string MAddress { get; set; }

        [DisplayName("会员邮箱")]
        [DataType(DataType.EmailAddress, ErrorMessage = "会员邮箱格式不符合")]
        /// <summary>
        /// 会员邮箱
        /// </summary>
        public string MEmail { get; set; }

        [DisplayName("会员微信号")]
        /// <summary>
        /// 会员微信号
        /// </summary>
        public string MWechat { get; set; }
        [DisplayName("备注说明")]
        /// <summary>
        /// 备注说明
        /// </summary>
        public string MRemark { get; set; }

        public MMS.Model.MemberInfo ToModel()
        {
            return new MMS.Model.MemberInfo()
            {
                MAddress = this.MAddress,
                MBalances = this.MBalances,
                MBirthday = this.MBirthday,
                MCardId = this.MCardId,
                MConsumption = this.MConsumption,
                MEmail = this.MEmail,
                MGender = this.MGender,
                MId = this.MId,
                MIntegral = this.MIntegral,
                MLId = this.MLId,
                MName = this.MName,
                MOccupation = this.MOccupation,
                MPassword = this.MPassword,
                MPhone = this.MPhone,
                MRemark = this.MRemark,
                MWechat = this.MWechat
            };
        }
    }
}